﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Apps.Model.Attendance;
using EzDesk.Apps.ServiceImpl.Attendance.Repositories;
using EzDesk.Apps.ServiceImpl.Attendance.Repositories.Interface;
using EzDesk.Apps.ServiceImpl.Repositories.Mock;

namespace EzDesk.Apps.UnitTest
{

    public class Mock_EvaluationModifyHistoryRepository :
        Mock_Repository<EvaluationModifyHistory>, IEvaluationModifyHistoryRepository
    {
        public IList<EvaluationModifyHistory> GetModifyHistoryByUserAndDate(Guid userId, DateTime date)
        {
            return innerStorage
                .GetAll()
                .Where(p => p.UserId == userId && p.Date == date.Date)
                .OrderByDescending(p => p.ModifyOn)
                .ToList();
        }

        public void AddModifyHistory(
            DayAttendanceEvaluation oldAttendanceEvaluation, 
            DayAttendanceEvaluation newAttendanceEvaluation, 
            Guid operatorId, 
            DateTime modifyOn)
        {
            var newHitory = new EvaluationModifyHistory()
                                {
                                    Id = Guid.NewGuid(),
                                    Date = oldAttendanceEvaluation.Date,
                                    UserId = oldAttendanceEvaluation.UserId,
                                    ModifyOn = DateTime.Now,
                                    OperatorId = operatorId,
                                    AttendanceEvaluationChangeList = new List<EvaluationModifyHistoryChangeItem>()
                                };
            innerStorage.Add(newHitory, true);
        }
    }
}
